package com.horse.pack.controller;

import com.horse.pack.common.GeneralResponse;
import com.horse.pack.model.res.ProductClassifyRes;
import com.horse.pack.model.res.ProductDetailRes;
import com.horse.pack.model.res.ProductRes;
import com.horse.pack.service.KfcApp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yangliu
 * @date 2024/3/22 11:33 AM
 */
@RestController
@RequestMapping("/kfc")
public class KfcController {

    @Resource
    private KfcApp kfcApp;

    /**
     * 查询商品分类
     * @param storeCode
     * @param type
     * @param deliverType
     * @return
     */
    @GetMapping("/queryProductClassify")
    public GeneralResponse queryProductClassify(@RequestParam("storeCode")String storeCode,
                                                @RequestParam("type")Integer type,@RequestParam("deliverType")Integer deliverType) {
        List<ProductRes> productClassifyResList = kfcApp.queryProductClassify(storeCode, type, deliverType);
        return GeneralResponse.success(productClassifyResList);
    }

    /**
     * 查询商品明细
     * @param storeCode
     * @param type
     * @param deliverType
     * @return
     */
    @GetMapping("/queryProductDetail")
    public GeneralResponse queryProductDetail(@RequestParam("storeCode")String storeCode,
                                                @RequestParam("type")Integer type,
                                                @RequestParam("deliverType")Integer deliverType,
                                                @RequestParam("productId")String productId) {
        List<ProductDetailRes> productClassifyResList = kfcApp.queryProductDetail(storeCode, type, deliverType,productId);
        return GeneralResponse.success(productClassifyResList);
    }
}
